
package nl.rainbowsheep.reisorg.empl.site.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 *Controller voor het inloggen
 */
@Controller
public class LoginController {

    @RequestMapping(value = "/logout", method = RequestMethod.GET)
    public String logoutPage() {
        return "logout";
    }

    /**
     * TODO: show error which you get back from the server. 
     * 
     * @param auth
     * @param map
     * @return 
     */
    @RequestMapping(value = "/loginPage", method = RequestMethod.GET)
    public String loginPage(@RequestParam(value="auth", required=false, defaultValue = "true") String auth, ModelMap map) {
        if (auth.equals("fail")) {
            map.addAttribute("loginError", "loginError");
            return "login"; 
        }
        else {
        return "login";
        }
    }
}
